<template>
  <div class="comment-post" >
    <div class="send" v-if="this.$store.state.user">
      <textarea
        name
        id
        cols="80"
        rows="3"
        :placeholder="whoName?'回复  '+whoName:'请自觉遵守互联网相关的政策法规，严禁发布色情、暴力、反动的言论。'"
        class="send-input"
        v-bind:value="value"
        v-on:input="$emit('input', $event.target.value)"
        :maxlength="maxlength?maxlength:-1"
      ></textarea>
      <span v-if="maxlength" class="word-count">{{value.length}}/{{maxlength}}</span>
      <ElButton type="primary" class="send-btn" @click="handleClick()">{{btnText?btnText:'发表评论'}}</ElButton>
      
    </div>
    <div class="nologin" v-else>
        <div class="text">
            您还未登录，请
                <router-link :to="{name:'login'}">登录</router-link>
            后在发表评论。
        </div>
        
    </div>
  </div>
</template>

<script>
export default {
  name: "comment-post",
  //submitComment 评论发表回调函数
  props: ["submit", "value","whoName","btnText","maxlength"],
  data: function() {
    return {};
  },
  methods: {
      handleClick(){
          console.log("huifu")
          this.submit()
      }
  }
};
</script>

<style lang="scss" scoped>
.comment-post {
  .send{
      position: relative;
      display: flex;
  }
  .send-input {
    resize: none;
    font-size: 12px;
    display: inline-block;
    box-sizing: border-box;
    background-color: #f4f5f7;
    border: 1px solid #e5e9ef;
    overflow: auto;
    border-radius: 4px;
    color: #555;
    width: 100% !important;
    height: 65px;
    transition: 0s;
    padding: 5px 10px;
    line-height: normal;
    outline: none;
    &:focus {
      border: 1px solid #409eff;
      background-color: #ffffff;
    }
  }
  .send-btn {
   // position: absolute;
    top: 0;
    right: -76px;
    width: 75px;
    height: 64px;
    white-space: normal;
  }
  .nologin{
      
      background: #e5e9ef;
      border-radius: 5px;
      height: 65px;
      width: 100%;
      line-height: 65px;
      text-align: center;
  }
  .word-count{
    position: absolute;
    right: 78px;
    bottom: 5px;
    color: #aaaaaa;
  }
}
</style>